#include "FlashElement.hpp"

FlashElement::FlashElement(float x, float y, float angle, const b2Vec2 impulse, b2World* world) {
    this->impulse = new b2Vec2(impulse.x, impulse.y);
    this->numberOfContacts = 0;

    b2BodyDef bodyDefinition;
    bodyDefinition.userData = this;
    bodyDefinition.position.Set(x, y);
    bodyDefinition.angle = angle;

    b2Vec2 vertices[4];
    vertices[0].Set(-0.5f, 0.025f);
    vertices[1].Set(0.5f, 0.025f);
    vertices[2].Set(0.5f, 0.05f);
    vertices[3].Set(-0.5f, 0.05f);

    b2PolygonShape shape;
    shape.Set(vertices, 4);

    b2FixtureDef fixtureDefinition;
    fixtureDefinition.shape = &shape;
    fixtureDefinition.isSensor = true;

    this->body = world->CreateBody(&bodyDefinition);
    this->body->CreateFixture(&fixtureDefinition);
}

FlashElement::~FlashElement() {
    delete this->impulse;
}

bool FlashElement::isFlash() {
    return true;
}
